﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Linq;

namespace WpfStudy
{
    public class NameStyleSelector:StyleSelector
    {
        public override System.Windows.Style SelectStyle(object item, System.Windows.DependencyObject container)
        {
            Customer customer = item as Customer;
            Window window = Application.Current.Windows.Cast<Window>().FirstOrDefault(c => c.IsActive);
            if (customer.Name == "Jason")
                return (Style)window.FindResource("jasonStyle");
            else
                return (Style)window.FindResource("otherStyle");
        }
    }
}
